<?php
/*
    CREATE TABLE `testimonials` (
	`id` INT(10) NOT NULL AUTO_INCREMENT,
	`franchise_id` INT(10) NOT NULL,
	`date_created` DATE NULL DEFAULT NULL,
	`date_updated` DATE NULL DEFAULT NULL,
	`customer_id` INT(10) NOT NULL,
	`headline` VARCHAR(255) NULL DEFAULT NULL,
	`content` TEXT NULL,
	`status` TINYINT ZEROFILL NULL DEFAULT '1',
	PRIMARY KEY (`id`)
)
COLLATE='utf8_general_ci'
ENGINE=InnoDB;
     */
    
class Testimonials_model extends CI_Model {
    protected $_tableTestimonials = "franchise_testimonials";
    protected $_tableUsers = "users";
    function __construct() {
        parent::__construct();
	$this->load->database();
    }       

    public function loadTestimonialsListById($id = 0){
         $this->db->where('status', '1');
         $this->db->where('franchise_id', $id);
         $this->db->order_by("date_updated","desc");
         return $this->db->get('franchise_testimonials')->result_array();
     }   
    
    public function loadFranchiseNameById($id = 0){
        $this->db->select('name');
         $this->db->where('status', '1');
         $this->db->where('id', $id);
         return $this->db->get('franchise')->row_array();
     }   
    
     public function getLastestTestimonial($id = 0){
         $this->db->select('content');
         $this->db->where('status', '1');
         $this->db->where('franchise_id', $id);
         $this->db->order_by("date_updated","desc");
         return $this->db->get('franchise_testimonials')->row_array();
     }   
}
?>